/*
	FileName : app_led.c
	Description : 
	
	Created on 2013.10.27 by ZZP.
	
	Revision History:
	
*/

#include "bsp.h"
#include "app.h"
#include "app_led.h"


uint16_t	ComLedTm;
uint16_t	CanLedTm;
uint16_t	TaxLedTm;
	
void ComLed(void);
void CanLed(void);
void TaxLed(void);

/////////////////////////////////////////////////////////////////////////////////
///							Global Function realizations
/////////////////////////////////////////////////////////////////////////////////
void AppTaskLED(void *p_arg)
{
	(void)p_arg;

	while (DEF_TRUE){
		
		if (AppInfo.RdyFlag){
			
			ComLed();
			CanLed();
			TaxLed();
		}
		
		AppInfo.TaskLedCnt++;
		
		OSTimeDly(10);
	}
}

/////////////////////////////////////////////////////////////////////////////////
///							Local Function realizations
/////////////////////////////////////////////////////////////////////////////////

void ComLed(void)
{
	if (AppInfo.ComLedFlag){
		
		if (ComLedTm >= 3){
			
			BSP_LED_Off(LED_COM);
			ComLedTm = 0;
			AppInfo.ComLedFlag--;
		}
		else if (ComLedTm > 1)
			BSP_LED_Off(LED_COM);
		else
			BSP_LED_On(LED_COM);
		
		ComLedTm++;
	}
	else
		ComLedTm = 0;
}

void CanLed(void)
{
	if (AppInfo.CanLedFlag){
		
		if (CanLedTm >= 3){
			
			CanLedTm = 0;
			AppInfo.CanLedFlag--;
		}
		else if (CanLedTm > 1)
			BSP_LED_Off(LED_CAN);
		else
			BSP_LED_On(LED_CAN);
		
		CanLedTm++;
	}
	else
		CanLedTm = 0;
}

void TaxLed(void)
{
	if (AppInfo.TaxLedFlag){
		
		if (TaxLedTm >= 3){
			
			TaxLedTm = 0;
			AppInfo.TaxLedFlag--;
		}
		else if (TaxLedTm > 1)
			BSP_LED_Off(LED_TAX);
		else
			BSP_LED_On(LED_TAX);
		
		TaxLedTm++;
	}
	else
		TaxLedTm = 0;
}











